import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import { createPinia } from 'pinia'
import i18n from '@/i18n'

import 'font-awesome/css/font-awesome.min.css'

const app = createApp(App)
app.use(createPinia()).use(router).use(i18n).mount('#app')

// 注册 (函数指令)
app.directive('lazyload', (el, binding) => {
  const observer = new IntersectionObserver(([{ isIntersecting }]) => {
    //如进入了可视区
    if (isIntersecting) {
      //2.给图片的src属性赋值图片的地址
      el.src = binding.value
      //3.取消图片监听
      observer.unobserve(el)
    }
  })
  observer.observe(el)
})
